package com.example.wordpress;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class PostListItemClickListener implements OnItemClickListener {
	
	private final MainActivityView mainActivityView;
	
	public PostListItemClickListener(MainActivityView view) {
		mainActivityView = view;
	}
	
	@Override
	public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
		Post post = (Post) adapter.getAdapter().getItem(position);
		/* Lanzar editor */
		Activity activity = mainActivityView.getActivity();
    	Intent intent = new Intent(activity, Editor.class);
    	intent.putExtra("post_id", post.getId());
    	intent.putExtra("blog_id", post.getBlogId());
    	activity.startActivityForResult(intent, MainActivityCtrl.REQUEST_EDITOR);
	}
}
